﻿using FFImageLoading.Svg.Forms;
using RSDriverAndroid.Views;
using RSModels.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace RSDriverAndroid
{
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
            Views = new List<View>()
            {
                new AccountView(),
                new TaskView(Tasks),
            };
            AccountIcon.Source = SvgImageSource.FromFile("user_s.svg");
            AccountText.TextColor = Color.FromRgb(0, 150, 136);
            TaskIcon.Source = SvgImageSource.FromFile("task.svg");
            TaskText.TextColor = Color.FromRgb(68, 68, 68);
            NavigateTo("我的", Views[0]);
        }

        public List<View> Views { get; set; }

        public ObservableCollection<RSTask> Tasks { get; set; } = new ObservableCollection<RSTask>();

        private void NavigateTo(string title, View view)
        {
            if (view != null && ContentArea.Content != view)
            {
                TitleLabel.Text = title;
                ContentArea.Content = view;
            }
        }

        private void Button_Clicked(object sender, EventArgs e)
        {
            AccountIcon.Source = SvgImageSource.FromFile("user_s.svg");
            AccountText.TextColor = Color.FromRgb(0, 150, 136);
            TaskIcon.Source = SvgImageSource.FromFile("task.svg");
            TaskText.TextColor = Color.FromRgb(68, 68, 68);
            NavigateTo("我的", Views[0]);
        }

        private void Button_Clicked_1(object sender, EventArgs e)
        {
            AccountIcon.Source = SvgImageSource.FromFile("user.svg");
            AccountText.TextColor = Color.FromRgb(68, 68, 68);
            TaskIcon.Source = SvgImageSource.FromFile("task_s.svg");
            TaskText.TextColor = Color.FromRgb(0, 150, 136);
            NavigateTo("任务", Views[1]);
        }
    }
}
